import React from 'react';
import { ExclamationCircleFilled } from '@ant-design/icons';
import { Button, Modal } from 'antd';
import { connect } from 'react-redux';
import { update_order } from '../../../store/actions/order';
const { confirm } = Modal;

const ConfirmModal = props => {
  const { title, btnCont, id, update_order } = props;
  const showConfirm = () => {
    confirm({
      title,
      width: 300,
      icon: <ExclamationCircleFilled />,
      onOk() {
        // 修改状态，id ，状态orderState==>已关闭
        update_order({ id, newState: { orderState: '已关闭' } });
      },
    });
  };
  return (
    <Button type='link' onClick={showConfirm}>
      {btnCont}
    </Button>
  );
};

// 改装组件
export default connect(
  state => ({
    state: state.orderReducer,
  }),
  { update_order }
)(ConfirmModal);
